import { defineStore } from 'pinia'
//import request from '@/pages/request/api.js'


//定义一个名为 user 的 store
export const useUserStore  = defineStore('user', {
  state: () => ({
    // 在这里定义你要存储在全局的数据，例如用户信息
    userInfo:null,
    count: 0,
	catergoryDeatil:null,
	clazz:null
  }),
  getters: {
    // 可以定义一些计算属性，例如获取用户姓名
    getUserName: (state) => state.userInfo?.username,
	getRole: (state) => state.userInfo?.role,
	getMoney: (state) => state.userInfo?.money,
	getPoints: (state) => state.userInfo?.points,
	getImgPath: (state) => state.userInfo?.imgPath,
	getPhone: (state) => state.userInfo?.phone,
	getUserId: (state) => state.userInfo?.userId,
	getPassWord: (state) => state.userInfo?.password,
	
	getCourseName:(state)=> state.clazz?.courseName,
	getCourseId:(state)=> state.clazz?.courseId,
	getDescription:(state)=> state.clazz?.description,

	getCategoryId:(state)=> state.clazz?.categoryId,
	getCategoryName:(state)=> state.clazz?.categoryName
  },
  actions: {
    // 定义修改数据的方法，例如设置用户信息
    setUserInfo(data) {
      this.userInfo = data
    },
	setCatergoryDeatil(data){
		this.catergoryDeatil =data
	},
	setClazz(data){
		this.clazz =data
	},
    increment() {
      this.count++
    }
  }
})